Tool Mentor: Reverse-Engineering CodePurposeThis tool mentor describes how to use Rational Rose® to reverse-engineer existing code into elements in the Artifact: Design Model. Reverse engineering source code with Rational Rose requires a Rational Rose Language Support add-in that is compatible with that source code, such as Rose J (for Java) or Rose Visual C++. Related Rational Unified Process activity: section "Reverse-engineer components and databases" in Activity: Incorporate Existing Design Elements. OverviewReverse engineering is the process of examining an existing source or binary code project to recover information about its design, then using that information to generate or update a model representing the project's logical structure. A code project corresponds to a component in the component view of a model. Reverse engineering is performed between the project or source file and the target model. You can use Rational Rose to reverse-engineer existing code into a design model in three ways:
1. Create a New Model by
Reverse-engineering code
In this case, you are starting with an existing implementation that you bring into your model. When you reverse-engineer existing source, you use the Rational Rose Tools menu to select the appropriate language or data base add-in. When reverse-engineering is complete, you can create the diagrams you use to visualize your project and further develop the model.
2. Update an Existing Model by
Reverse-engineering code
In this case, you have an existing model and you're introducing source code to reflect existing implementation. As you develop the model and source, you can continue to update the model with your changes.
3. Add External
Components to a Model
External components are classes that are not implemented in your application. Instead, they are referenced or are sub-classed by model classes and by code implemented in your application, such as COM objects, or Microsoft®Foundation Classes (MFC). Because they are not implemented in your application’s code, only their interface and internal documentation are reverse engineered. This limited form of reverse engineering is called Importing. Note: This process should be restricted to components that are external to the model, or that will be sub-classed in the model. External classes should have their Generate Code flag set to false. To access objects from your model, simply drag and drop them (.dll, .exe, .ocx, or .tlb) from the Explorer into an open component diagram, a component package, or onto a logical package in the browser.
Note that two conditions must be met before you can drag-and-drop a COM object into your model:
If both of these conditions are not met, the drop into the model is ignored.
4. Packaging and Diagramming
Reverse-Engineered Classes
When Rational Rose reverse engineers or imports code information, it assigns the resulting model data to a package (with the same name as the project) under the Reverse Engineered package, or to an MFC package, as appropriate. Diagramming these components, or adding them to other packages, is left up to you. Diagramming Reverse-Engineered projects Diagramming a model is a very subjective process. For this reason, the reverse engineering process generates model data only. It does not generate model diagrams. You can add classes to a diagram in either of two ways:
Arrange the diagrammed components to illustrate the architecture of the system. Avoid crossed association lines by moving the classes in the diagram. You can use the Diagram Object Properties command on the Edit menu to control the level of class details in a diagram. Dropping Classes into a Diagram You can add a class to a diagram simply by opening the diagram, then dragging and dropping the individual classes from the browser into the diagram. The Add Classes Dialog Box You can use the Add Classes dialog box to move classes from a package to the active diagram. The selected classes are added to the active diagram. Arrange the added classes to best illustrate the architecture of the system. Adding Reverse-Engineered Classes to Packages While you may leave your new classes in their reverse-engineered project package, can also move or copy them to other packages in your system. There are four ways to move a class from one package to another:
|
Rational Unified
Process |